/*
@author   : wang lingcong
@date     : 2022/10/31
@desc     : store入口文件，提供useAppDispatch/useAppSelector hooks
*/
import { configureStore } from '@reduxjs/toolkit'
import { useDispatch, useSelector } from 'react-redux'
import address from './address'
import counter from './counter'
import payCenter from './payCenter'
import changeCourse from './changeCourse'
import confirmPay from './confirmPay'
import logger from 'redux-logger'
import type { TypedUseSelectorHook } from 'react-redux'

const store = configureStore({
  reducer: { counter, address, payCenter, confirmPay, changeCourse },
  devTools: process.env.NODE_ENV !== 'production',
  //middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(logger),
})

export default store

export type AppDispatch = typeof store.dispatch
export type RootState = ReturnType<typeof store.getState>
export const useAppDispatch: () => AppDispatch = useDispatch
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector
